﻿using System;
using System.Collections.Generic;
using System.Text;
using static Asion.Dapper.SqlMapperExtensions;

namespace Asion.Dapper.SqlBuilder
{
    public abstract class AbstractSimpleCrudSqlBuilder<TEntity> where TEntity : IEntity
    {
        public AbstractSimpleCrudSqlBuilder()
        {
            var type = typeof(TEntity);
            TEntityType = type;
            var info = SqlMapperExtensions.GetPropertiesCache(new PropertyIdentity(typeof(TEntity)));
            _custom_table_mappinghandle = new SimpleCustomTableMappingHandle(info);
            this.TableMapping = info;
            this.TableName = info.TableName;
            this.Columns = info.Columns;
        }


        public ICustomTableMappingHandle _custom_table_mappinghandle;

        private Type TEntityType { get; set; }

        /// <summary>
        /// colums
        /// </summary>
        public IEnumerable<CustomColumnMapping> Columns { get; set; }


        /// <summary>
        ///  table name
        /// </summary>
        public string TableName { get; set; }

        /// <summary>
        ///  table mapping
        /// </summary>
        public CustomTableMapping TableMapping { get; set; }


        public abstract string GetIdentitySql();


        public abstract string GetPagedTemplate();

        public Type GetTEntityType()
        {
            return this.TEntityType;
        }

    }
}
